{extend name='base' /}
{block name='content'}
<body>
<div class="x-nav">
      <span class="layui-breadcrumb">
        <a href="">后台管理</a>
        <a href="">用户管理</a>
        <a>
          <cite>用户列表</cite></a>
      </span>
  <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right" href="javascript:location.replace(location.href);" title="刷新">
    <i class="layui-icon" style="line-height:30px">ဂ</i></a>
</div>
<div class="x-body">
  <div class="layui-row">
    <form class="layui-form layui-col-md12 x-so" method="get">
      <input type="text" name="nickname" placeholder="请输入用户昵称" autocomplete="off" class="layui-input" value="<?php echo $nickname = isset($_GET['nickname'])?$_GET['nickname']:'';?>">
      <input type="text" name="phone" placeholder="请输入用户手机号" autocomplete="off" class="layui-input" value="<?php echo $phone = isset($_GET['phone'])?$_GET['phone']:'';?>">
      <input type="text" name="time" placeholder="请选择注册时间" id="test10" autocomplete="off" class="layui-input" value="<?php echo $time = isset($_GET['time'])?$_GET['time']:'';?>">
      <button class="layui-btn" lay-submit="" lay-filter="sreach"><i class="layui-icon">&#xe615;</i></button>
    </form>

  </div>
  <xblock>
    <button class="layui-btn" onclick="x_admin_show('添加用户','{:url('user/add')}')"><i class="layui-icon"></i>添加
    </button>
  </xblock>
  <table class="layui-table">
    <thead>
    <tr>

      <th>ID</th>
      <th>用户昵称</th>
      <th>性别</th>
      <th>手机号</th>
      <th>余额</th>
      <th>累计充值</th>
      <th>注册时间</th>
      <th>注册方式</th>
      <th>状态</th>
      <th>操作</th>
    </thead>
    <tbody>
{volist name='userData' id='vo'}
    <tr>

      <td>{$vo.id}</td>
      <td>{$vo.nickname}</td>
      <td>
        {if $vo.sex==1}
        女
        {else /}
        男
        {/if}
      </td>
      <td>{$vo.phone}</td>
      <td> {$vo.balance}</td>
      <td>
        {$vo.cumulative}
      </td>
      <td>{$vo.register_time|date='Y-m-d H:i:s',###}</td>
      <td>
        {switch name="$vo.register_way"}
        {case value="1"}<span class="layui-btn layui-btn-normal layui-btn-xs">后台添加</span>{/case}
        {case value="2"}<span class="layui-btn layui-btn-info layui-btn-xs">平台注册</span>{/case}
        {case value="3"}<span class="layui-btn layui-btn-primary layui-btn-xs">游戏注册</span>{/case}
        {default /}default
        {/switch}
      </td>
      <td class="td-status">
        {if $vo.lock_status==1}
        <span class="layui-btn layui-btn-normal layui-btn-xs">正常</span>
        {else /}
        <span class="layui-btn layui-btn-danger layui-btn-xs">已锁定</span>
        {/if}
      </td>
      <td class="td-manage">
        <div class="layui-btn-group">
          {if $vo.lock_status==1}
          <a onclick="member_stop(this,{$vo.id})" href="javascript:;" class="layui-btn layui-btn-warm layui-btn-xs" stu="{$vo.lock_status}">

            锁定

          </a>
          {else / }
          <a onclick="member_stop(this,{$vo.id})" href="javascript:;" class="layui-btn layui-btn-info layui-btn-xs" stu="{$vo.lock_status}">

            解锁

          </a>

          {/if}
          <a href="javascript:;" class="layui-btn layui-btn-normal layui-btn-xs" onclick=" x_admin_show('规则编辑','{:url('user/edit','id='.$vo.id)}')">编辑</a>
          <a class="layui-btn layui-btn-danger layui-btn-xs" onclick="member_del(this,{$vo.id})" href="javascript:;">删除</a>
        </div>
      </td>
    </tr>
{/volist}
    </tbody>
  </table>
  <div class="page">
    <div>
      {$userData->render()}
    </div>
  </div>

</div>
<script>
    layui.use('laydate', function() {
        var laydate = layui.laydate;
        laydate.render({
            elem: '#test10'
            ,type: 'datetime'
            ,range: true
        });
    })

    /*用户-停用*/
    function member_stop(obj,id){
            var sta = $(obj).attr('stu');
            if (sta==1){
                var str ='确认要锁定用户吗？'
            } else{
                var str ='确认要解锁用户吗？'
            }
            layer.confirm(str, function (index) {
                $.ajax({
                    url:"{:url('user/upSta')}",
                    type:'post',
                    dataType:'json',
                    data:{id:id,sta:sta},
                    success:function (res) {
                        if (res.code) {
                            layer.msg(res.message, {icon: 6, time: 1000});
                            setTimeout(function () {
                                window.location.reload();
                            },1000)

                        } else {
                            layer.msg(res.message, {icon: 2, time: 1000})
                        }
                    },
                    error:function () {
                        layer.msg('出错了，请稍后再试！！', {icon: 5, time: 1000})
                    }
                })


            });
    }

    /*用户-删除*/
    function member_del(obj,id){
        layer.confirm('确认要删除吗？', function (index) {
            // //发异步删除数据
            $.ajax({
                url: "{:url('user/del')}",
                data: {id: id},
                type: 'post',
                dataType: 'json',
                success: function (res) {
                    if (res.code) {
                        $(obj).parents("tr").remove();
                        layer.msg(res.message, {icon: 6, time: 1000});
                    } else {
                        layer.msg(res.message, {icon: 2, time: 1000})
                    }
                },
                error: function () {
                    layer.msg('出错了，请稍后再试！！', {icon: 5, time: 1000})
                }
            })

        });
    }




</script>

</body>
{/block}